package com.jy.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.pojo.Teacher;
import com.jy.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("teacher")
public class TeacherController {
    @Autowired
    TeacherService teacherService;

    @RequestMapping("findPage")
    public Page<Teacher> findPage(Integer pn, Integer ps, @RequestBody Teacher teacher) {
        return teacherService.findPage(pn, ps, teacher);
    }

    @RequestMapping("deleteIdArr")
    public boolean deleteIdArr(@RequestBody List<Integer> idArr) {
        teacherService.removeBatchByIds(idArr);
        return true;
    }

    @RequestMapping("deleteById")
    public boolean deleteById(Integer id) {
        teacherService.removeById(id);
        return true;
    }

    @RequestMapping("upadd")
    public boolean upadd(@RequestBody Teacher teacher) {
        teacherService.saveOrUpdate(teacher);
        return true;
    }
}
